package com.bw.gmall.realtime.dws.function;

import com.bw.gmall.realtime.dws.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.Set;

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public  class SplitFunction extends TableFunction<Row> {

    public void eval(String str) {
        Set<String> split = IkUtil.split(str);
        if (str == null) {
            return;
        }

        for (String s : split) {
            // use collect(...) to emit a row
            collect(Row.of(s));
        }
    }
}
